
<template>
  <div>
    <Header></Header>
    <div class="crumb">
      <div class="w">
        <div class="crumb-con">
          <a class="link" href="./index.html">睿购商城</a>
          <span>&gt;</span>
          <span class="link-text">商品详情</span>
        </div>
      </div>
    </div>
    <div class="page-wrap w">
      <div class="intro-wrap">
        <div class="p-img-con">
          <div class="main-img-con">
            <img class="main-img" src="../assets/tv-big.jpg">
          </div>
          <ul class="p-img-list">
            <li class="p-img-item">
              <img class="p-img" src="../assets/tv-ssmall.jpg">
            </li>
          </ul>
        </div>
        <div class="p-info-con">
          <h1 class="p-name">{{itemDetail.name}}</h1>
          <p class="p-subtitle">{{itemDetail.subtitle}}</p>
          <div class="p-info-item p-price-con">
            <span class="label">价格:</span>
            <span class="info">{{itemDetail.price}}</span>
          </div>
          <div class="p-info-item">
            <span class="label">库存:</span>
            <span class="info">{{itemDetail.stock}}</span>
          </div>
          <div class="p-info-item p-count-con">
            <span class="label">数量:</span>
            <input class="p-count" value="1" readonly="">
            <span class="p-count-btn plus">+</span>
            <span class="p-count-btn minus">-</span>
          </div>
          <div class="p-info-item">
            <router-link :to="{'name':'cart','query':{'productId':itemDetail.id,'count':this.count}}"
                         class="btn cart-add" >加入购物车
            </router-link>
          </div>
        </div>
      </div>
      <div class="detail-wrap">
        <div class="detail-tab-con">
          <ul class="tab-list">
            <li class="tab-item active">详细描述</li>
          </ul>
        </div>
        <div class="detail-con">
          <p>
            <img src="../assets/sony1.png" width="790" height="600">
            <img src="../assets/sony2.png" width="790" height="600">
            <img src="../assets/sony3.png" width="790" height="600">
            <img src="../assets/sony4.png" width="790" height="600">
            <br>
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
    import Header from "../components/Header";
    export default {
        name: "ItemDetail",
      data(){
        return {
          productId: '',
          count: 1,
          itemDetail: {}
        }
      },
      components:{Header},
      created() {
        //在生命周期回调方法中接受上一个路由传递过来的参数
        //route对象的query对象的categoryId属性
        this.productId = this.$route.query.productId;
        this.getItemDetail()
      },
      methods:{
        //查询商品列表的方法
        getItemDetail:function () {
          this.axios.get('/product/detail.do',{params:{'productId':this.productId}})
            .then( (response) => {
              console.log(response.data.data);
        this.itemDetail = response.data.data
})
}
}
}
</script>

<style scoped>
/* å›¾ç‰‡åŒº */
.intro-wrap{
  overflow: hidden;
}
.intro-wrap .p-img-con{
  float: left;
  width: 420px;
}
/* ä¸»å›¾ */
.intro-wrap .p-img-con .main-img-con{
  height: 400px;
  border: 1px solid #ddd;
}
.intro-wrap .p-img-con .main-img-con .main-img{
  height: 100%;
  width: 100%;
}
/* ç¼©ç•¥å›¾ */
.intro-wrap .p-img-con .p-img-list{
  overflow: hidden;
  height: 76px;
  margin-top: 5px;
  margin-right: -10px;
}
.intro-wrap .p-img-con .p-img-item{
  float: left;
  margin-right: 10px;
  width: 72px;
  height: 72px;
  border: 2px solid #eee;
  cursor: pointer;
}
.intro-wrap .p-img-con .p-img-item:hover{
  border: 2px solid #FF8800;
}
.intro-wrap .p-img-con .p-img-item .p-img{
  width: 100%;
  height: 100%;
}
/* å•†å“ä¿¡æ¯ */
.intro-wrap .p-info-con{
  float: left;
  width: 640px;
  margin-left: 20px;
}
.intro-wrap .p-info-con .p-name{
  font-size: 20px;
  color: #333;
}
.intro-wrap .p-info-con .p-subtitle{
  font-size: 15px;
  color: #FF8800;
  line-height: 30px;
}
.intro-wrap .p-info-con .p-info-item{
  position: relative;
  padding: 0 10px;
  margin-top: 20px;
}
.intro-wrap .p-info-con .p-info-item .label{
  display: inline-block;
  width: 50px;
  color: #999;
}
/* ä»·æ ¼éƒ¨åˆ† */
.intro-wrap .p-info-con .p-price-con{
  background: #eee;
  padding: 10px;
}
.intro-wrap .p-info-con .p-price-con .info{
  color: #FF8800;
  font-size: 18px;
}
/* æ•°é‡éƒ¨åˆ† */
.intro-wrap .p-info-con .p-count-con .p-count{
  height: 36px;
  line-height: 36px;
  font-size: 15px;
  width: 45px;
  text-align: center;
  outline: none;
  border: 1px solid #aaa;
}
.intro-wrap .p-info-con .p-count-con .p-count-btn{
  position: absolute;
  left: 115px;
  display: block;
  width: 20px;
  height: 15px;
  line-height: 15px;
  text-align: center;
  font-size: 10px;
  border: 1px solid #aaa;
  background: #fff;
  cursor: pointer;
  -moz-user-select : none;
  -webkit-user-select : none;
  -ms-user-select : none;
  user-select : none;
}
.intro-wrap .p-info-con .p-count-con .p-count-btn.plus{
  top: 0;
}
.intro-wrap .p-info-con .p-count-con .p-count-btn.minus{
  bottom: 0;
}
/* å•†å“è¯¦ç»†ä¿¡æ¯ */
.detail-wrap{
  margin-top: 15px;
}
.detail-wrap .tab-list{
  background: #eee;
  border: 1px solid #ddd;
  overflow: hidden;
  border-bottom: 1px solid #FF8800;
}
.detail-wrap .tab-list .tab-item{
  float: left;
  width: 100px;
  height: 50px;
  line-height: 50px;
  font-size: 16px;
  text-align: center;
  cursor: pointer;
}
.detail-wrap .tab-list .tab-item.active{
  background: #FF8800;
  color: #fff;
}
.detail-wrap .detail-con{
  padding-top: 20px;
  background: #fff;
}
.detail-wrap .detail-con img{
  display: block;
  margin: 0 auto;
}
/* é”™è¯¯ä¿¡æ¯ */
.err-tip{
  height: 60px;
  line-height: 60px;
  color: #f60;
  font-size: 16px;
  font-weight: bold;
  text-align: center;
  background: #eee;
}
</style>
